package com.tron.dobest.java.tronarithmetic;

import java.util.Arrays;

/**
 * 描述：
 *
 * @author TRON
 * @since 2020-06-07
 */
public class SelectSortStart {
    public static void main(String[] args) {
        int[] array = {10,2,4,9,8,6,3,1,5,7};
        //选择排序
        int count1 = 0;
        for (int i = 0; i < array.length; i++) {
            for (int j = i+1; j < array.length; j++) {
                count1 ++;
                int temp;
                if (array[j] < array[j - 1]) {
                    temp = array[j-1];
                    array[j-1] = array[j];
                    array[j] = temp;
                }
            }
        }
        System.out.println(Arrays.toString(array));
        System.out.println("比较次数："+count1);
    }
}
